home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1992 by Jon Dart. All Rights Reserved.
-
- #include "moveord.h"
-
- // We put this function in a separate file because it is the only
- // part of Move_Ordering that the "makebook" program needs.
-
- void Move_Ordering::sort_moves(Move moves[], int scores[], int n)
- {
- // uses Shell sort
-
- int gap, i, j, tj, tc;
- Move t;
-
- gap = n / 2;
- while (gap)
- {
- for (i = gap; i < n; i++)
- {
- j = i - gap;
- while (j >= 0)
- {
- tj = j + gap;
- if (scores[j] < scores[tj])
- {
- t = moves[j];
- moves[j] = moves[tj];
- moves[tj] = t;
- tc = scores[j];
- scores[j] = scores[tj];
- scores[tj] = tc;
- } else
- break;
- if (j >= gap)
- j -= gap;
- else
- break;
- }
- }
- gap /= 2;
- }
- }
-
-